import java.util.ArrayList;

public class RemoveElem {
    public static  int removeElement(int[] nums, int val) {
        ArrayList<Integer> list = new ArrayList<>();
        for(int x : nums){
            list.add(x);
        }
        int s = list.size();
        int count = 0;
        while(list.contains(val)){
            int  sub = list.indexOf(val);
            list.remove(sub);
            count++;
        }
        //for (int i = 0; i < list.size(); i++) {
        //    nums[i] = list.get(i);
        //  }
        return list.size();

    }
    public static void main(String[] args) {
        int[] nums = {0, 2, 2, 3, 0, 4, 2};
        int val = 2;
        int q = removeElement(nums, val);
        System.out.println(q);
    }
}
